<template>
  <view>



    <view class="gui-margin-top">
      <gui-article-list :articles="articleList" @newstap="newstap" :baseUrl="baseUrl"></gui-article-list>
    </view>
  </view>
</template>

<script>
  export default {
    data() {
      return {
        baseUrl: uni.gRequest.file,
        articleList: [{
            id: 2,
            title: '2月20日薛庄大席成功举行',
            author: '江小白',
            createTime: '2020.09.05',
            imgs: [
              '/static/images/daxi.jpg'
            ],
            views: 8052
          },
          {
            id: 3,
            title: '3月5日刘校长孙子满月宴成功圆满举行',
            author: '江小白',
            createTime: '2020.09.05',
            imgs: [
              '/static/images/daxi.jpg',
              '/static/images/daxi.jpg',
              '/static/images/daxi.jpg'
            ],
            views: 62012
          },
          {
            id: 4,
            title: '5月5日划龙舟比赛成功举行',
            author: '江小白',
            createTime: '2020.09.05',
            imgs: ['/static/images/daxi.jpg'],
            views: 680
          }

        ]
      }
    },
    onLoad() {
      this.initData();
    },
    methods: {
      initData() {
        uni.gRequest.get('news/list', {
          type: 2
        }).then(result => {
          // console.log('result', result);
          this.articleList = result.rows;
          this.articleList.forEach(x => {
            x.title = x.headline;
            x.imgs = x.image.split(',');
          });
          console.log(this.articleList)
        });
      },
      newstap(id) {
        console.log(id);
      }
    }
  }
</script>

<style>

</style>
